package br.com.dojo.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import br.com.dojo.dao.ContatoDAO;
import br.com.dojo.entity.Contato;

@Service
@Transactional
public class ContatoService {

	@Autowired
	ContatoDAO dao;

	public List<Contato> listarContatos() {
		List<br.com.dojo.entity.Contato> contatos = dao.findAll();
		List<Contato> result = new ArrayList<Contato>();
		for (br.com.dojo.entity.Contato contato : contatos) {
			Contato c = new Contato();
			c.setTelefoneResidencial(contato.getTelefoneResidencial());
			c.setTelefoneComercial(contato.getTelefoneComercial());
			c.setCelular(contato.getCelular());
			c.setEmail(contato.getEmail());
			result.add(c);
		}

		return result;
	}

}
